package com.atguigu.gmall.cart.client;

import com.atguigu.gmall.cart.client.impl.CartDegradeFeignClient;
import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.cart.CartInfo;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

@FeignClient(value ="service-cart",fallback = CartDegradeFeignClient.class)
public interface CartFeignClient  {

    /**
     * /api/cart/addToCart/{skuId}/{skuNum}
     * 加入购物车
     * @param skuId
     * @param skuNum
     * @param request
     * @return
     */
    @GetMapping("/api/cart/addToCart/{skuId}/{skuNum}")
    @ApiOperation("加入购物车")
    public Result addToCart(@PathVariable Long skuId,
                            @PathVariable Integer skuNum,
                            HttpServletRequest request);

    /**
     * /api/cart/cartList
     * @param request
     * @return
     */
    @GetMapping("/api/cart/cartList")
    @ApiOperation("查询购物车列表")
    public Result cartList(HttpServletRequest request);

    /**
     * /api/cart/checkCart/{skuId}/{isChecked}
     * @param skuId
     * @param isChecked
     * @param request
     * @return
     */
    //编写勾选状态
    @GetMapping("/api/cart/checkCart/{skuId}/{isChecked}")
    @ApiOperation("勾选状态")
    public Result checkCart(
            @PathVariable Long skuId,
            @PathVariable Integer isChecked,
            HttpServletRequest request
    );

    /**
     * /api/cart/deleteCart/{skuId}
     * @param skuId
     * @param request
     * @return
     */
    //删除购物车项
    @DeleteMapping("/api/cart/deleteCart/{skuId}")
    @ApiOperation("删除购物车项")
    public Result deleteCart(@PathVariable Long skuId, HttpServletRequest request);

    /**
     * 根据用户Id 查询购物车列表
     * /api/cart/getCartCheckedList/{userId}
     * @param userId
     * @return
     */
    @GetMapping("/api/cart/getCartCheckedList/{userId}")
    @ApiOperation("根据用户Id 查询购物车列表")
    public List<CartInfo> getCartCheckedList(@PathVariable Long userId);
}
